#include <cstdio>
#include <map>
#include <algorithm>

using namespace std;

#define N 150001
#define INF 2000000001

int max( int a, int b ) { return ( a > b )?a :b; }
int min( int a, int b ) { return ( a < b )?a :b; }

struct Node
{
    int x, y, f;
    Node( ) { }
    Node( int _x, int _y, int _f )
        : x( _x ), y( _y), f( _f ) { }
};

bool cmp1( const Node &a, const Node &b )
{
    if ( a.x != b.x ) return a.x < b.x;
    if ( a.y != b.y ) return a.y < b.y;
    return a.f < b.f;
}

bool cmp2( const Node &a, const Node &b )
{
    if ( a.x != b.x ) return a.x < b.x;
    if ( a.y != b.y ) return a.y > b.y;
    return a.f < b.f;
}

bool cmp3( const Node &a, const Node &b )
{
    if ( a.x != b.x ) return a.x > b.x;
    if ( a.y != b.y ) return a.y > b.y;
    return a.f < b.f;
}

bool cmp4( const Node &a, const Node &b )
{
    if ( a.x != b.x ) return a.x > b.x;
    if ( a.y != b.y ) return a.y < b.y;
    return a.f < b.f;
}

int n, q;
map<int, int> mp;
Node a[ N ];
int yy[ N ], v, c[ N ], ac[ N ];

int lowbit( int x )
{
    return x & ( x ^ ( x - 1 ) );
}

void update( int *c, int x, int vv )
{
    while ( x < v )
    {
        c[ x ] = max( c[ x ], vv );
        x += lowbit( x );
    }
}

int query( int *c, int x )
{
    int ans = -INF;
    while ( x > 0 )
    {
        ans = max( ans, c[ x ] );
        x -= lowbit( x );
    }
    return ans;
}

void init( )
{
    int i;
    for ( i = 0; i < n; i++ )
    {
        scanf("%d%d", &a[ i ].x, &a[ i ].y);
        a[ i ].f = i;
        yy[ i ] = a[ i ].y;
    }
    scanf("%d", &q);
    for ( i = 0; i < q; i++ )
    {
        scanf("%d%d", &a[ i + n ].x, & a[ i + n ].y);
        a[ i + n ].f = i + n;
        yy[ i + n ] = a[ i + n ].y;
        ac[ i ] = INF;
    }
    sort( yy, yy + n + q );
    mp.clear( );
    v = 1;
    for ( i = 0; i < n + q; i++ )
        if ( !mp[ yy[ i ] ] )
            mp[ yy[ i ] ] = v++;
}

void initc( )
{
    int i;
    for ( i = 1; i < v; i++ )
        c[ i ] = -INF;
}

void work( )
{
    int i, t;
    initc( );
    sort( a, a + n + q, cmp1 );
    for ( i = 0; i < n + q; i++ )
    {
        if ( a[ i ].f < n )
            update( c, mp[ a[ i ].y ], a[ i ].x + a[ i ].y );
        else
        {
            t = query( c, mp[ a[ i ].y ] );
            if ( t != -INF )
                ac[ a[ i ].f - n ] = min( ac[ a[ i ].f - n ], a[ i ].x + a[ i ].y - t );
        }
    }
    initc( );
    sort( a, a + n + q, cmp2 );
    for ( i = 0; i < n + q; i++ )
    {
        if ( a[ i ].f < n )
            update( c, v - mp[ a[ i ].y ], a[ i ].x - a[ i ].y );
        else
        {
            t = query( c, v - mp[ a[ i ].y ] );
            if ( t != -INF )
                ac[ a[ i ].f - n ] = min( ac[ a[ i ].f - n ], a[ i ].x - a[ i ].y - t );
        }
    }
    initc( );
    sort( a, a + n + q, cmp3 );
    for ( i = 0; i < n + q; i++ )
    {
        if ( a[ i ].f < n )
            update( c, v - mp[ a[ i ].y ], - a[ i ].x - a[ i ].y );
        else
        {
            t = query( c, v - mp[ a[ i ].y ] );
            if ( t != -INF )
                ac[ a[ i ].f - n ] = min( ac[ a[ i ].f - n ], -a[ i ].x - a[ i ].y - t );
        }
    }
    initc( );
    sort( a, a + n + q, cmp4 );
    for ( i = 0; i < n + q; i++ )
    {
        if ( a[ i ].f < n )
            update( c, mp[ a[ i ].y ], -a[ i ].x + a[ i ].y );
        else
        {
            t = query( c, mp[ a[ i ].y ] );
            if ( t != -INF )
                ac[ a[ i ].f - n ] = min( ac[ a[ i ].f - n ], -a[ i ].x + a[ i ].y - t );
        }
    }
    for ( i = 0; i < q; i++ )
        printf("%d\n", ac[ i ]);
}

int main( )
{
    bool blank = false;
    while ( scanf("%d", &n) && n != -1 )
    {
        if ( blank ) puts("");
        init( );
        work( );
        blank = true;
    }
}
